<?php
/**
 * 报量单模型
 */

namespace app\common\model;

use think\model\concern\SoftDelete;

class Dose extends CommonBaseModel {
	use SoftDelete;
	// 自定义选择数据
	public const TAG_TEXT = [0 => '套餐', 1 => '单品'];
	protected $name = 'dose';
	protected $autoWriteTimestamp = true;

	// 可搜索字段
	public array $searchField = [];

	// 可作为条件的字段
	public array $whereField = ['school_id', 'order_id'];

	// 可作为多选条件的字段
	public array $multiWhereField = [];

	// 可做为时间
	public array $timeField = ['week'];

	protected $json = ['detail', 'detail2'];
	protected $jsonAssoc = true;

	/**
	 * 关联
	 */
	public function school() {
		return $this->belongsTo(School::class);
	}
	public function getTagTextAttr($value, $data): string {
		return self::TAG_TEXT[$data['tag']];
	}
}
